const redisPool = require('./redisPool');
let _pool: any = null;

export const redisClientInit = () => {
  _pool = redisPool();
};

export const redisClientOpt = (...args: any) => {
  _pool.acquire().then((client) => {
    const [ type, key, value, time, cb ] = args;
    switch (type) {
      case 'get': 
        client.get(key, (err, res) => {
          _pool.release(client); 
          cb && cb(err, res); 
        });
        break;
      case'set': 
        client.set(key, value, (err, res) => {
          client.pexpire(key, time);
          _pool.release(client); 
          cb && cb(err, res); 
        });
        break;
      // 其他 Redis 命令的操作类似添加...
    }
  });
};
